namespace CollabApp.Domain.ValueObjects;

/// <summary>
/// 游戏常量配置 - 存储游戏核心规则的常量值
/// 确保游戏平衡性和一致性
/// </summary>
public static class GameConstants
{
    #region 基础游戏设定
    
    /// <summary>
    /// 默认游戏时长（秒）
    /// </summary>
    public const int DefaultGameDuration = 180;
    
    /// <summary>
    /// 快速模式游戏时长（秒）
    /// </summary>
    public const int FastGameDuration = 90;
    
    /// <summary>
    /// 竞技模式游戏时长（秒）
    /// </summary>
    public const int CompetitiveGameDuration = 300;
    
    /// <summary>
    /// 最大同时玩家数
    /// </summary>
    public const int MaxPlayersPerGame = 8;
    
    /// <summary>
    /// 最小玩家数（开始游戏）
    /// </summary>
    public const int MinPlayersToStart = 2;
    
    #endregion

    #region 地图设置
    
    /// <summary>
    /// 标准地图大小（像素）
    /// </summary>
    public const int StandardMapSize = 1000;
    
    /// <summary>
    /// 小地图大小（2-4人）
    /// </summary>
    public const int SmallMapSize = 800;
    
    /// <summary>
    /// 大地图大小（7-8人）
    /// </summary>
    public const int LargeMapSize = 1200;
    
    /// <summary>
    /// 出生点安全区域半径（像素）
    /// </summary>
    public const int SpawnSafeZoneRadius = 50;
    
    /// <summary>
    /// 地图边界缓冲区（像素）
    /// </summary>
    public const int MapBoundaryBuffer = 10;
    
    #endregion

    #region 移动和绘制
    
    /// <summary>
    /// 基础移动速度（像素/秒）
    /// </summary>
    public const float BaseMovementSpeed = 120f;
    
    /// <summary>
    /// 最大移动速度（像素/秒）
    /// </summary>
    public const float MaxMovementSpeed = 300f;
    
    /// <summary>
    /// 轨迹线宽度（像素）
    /// </summary>
    public const int TrailWidth = 2;
    
    /// <summary>
    /// 最大单次画线长度（地图对角线倍数）
    /// </summary>
    public const float MaxDrawingLengthMultiplier = 1.5f;
    
    /// <summary>
    /// 敌方领地内移动速度减缓比例
    /// </summary>
    public const float EnemyTerritorySpeedDebuff = 0.8f;
    
    /// <summary>
    /// 己方领地内移动速度加成比例
    /// </summary>
    public const float OwnTerritorySpeedBuff = 1.15f;
    
    #endregion

    #region 死亡和复活
    
    /// <summary>
    /// 复活等待时间（秒）
    /// </summary>
    public const int RespawnDelay = 5;
    
    /// <summary>
    /// 复活无敌时间（秒）
    /// </summary>
    public const int InvulnerabilityDuration = 5;
    
    /// <summary>
    /// 连续死亡惩罚时间（秒）
    /// </summary>
    public const int ContinuousDeathPenalty = 8;
    
    /// <summary>
    /// 死亡后保留的最大历史领地面积比例
    /// </summary>
    public const float DeathAreaRetentionRate = 0.2f;
    
    #endregion

    #region 道具系统
    
    /// <summary>
    /// 道具刷新间隔（秒）
    /// </summary>
    public const int PowerUpSpawnInterval = 25;
    
    /// <summary>
    /// 最大同时存在道具数量
    /// </summary>
    public const int MaxPowerUpsOnMap = 3;
    
    /// <summary>
    /// 道具狂欢模式道具数量倍数
    /// </summary>
    public const int PowerUpCarnivalMultiplier = 3;
    
    /// <summary>
    /// 闪电道具速度提升比例
    /// </summary>
    public const float LightningSpeedBoost = 1.6f;
    
    /// <summary>
    /// 闪电道具持续时间（秒）
    /// </summary>
    public const int LightningDuration = 8;
    
    /// <summary>
    /// 护盾道具持续时间（秒）
    /// </summary>
    public const int ShieldDuration = 12;
    
    /// <summary>
    /// 炸弹道具影响半径（像素）
    /// </summary>
    public const int BombRadius = 30;
    
    /// <summary>
    /// 幽灵道具持续时间（秒）
    /// </summary>
    public const int GhostDuration = 10;
    
    #endregion

    #region 特殊机制
    
    /// <summary>
    /// 提前结束所需的地图控制百分比
    /// </summary>
    public const float EarlyEndAreaThreshold = 70f;
    
    /// <summary>
    /// 橡皮筋联盟触发的领先优势阈值
    /// </summary>
    public const float RubberBandAllianceThreshold = 40f;
    
    /// <summary>
    /// 地图缩圈开始时间（剩余秒数）
    /// </summary>
    public const int MapShrinkingStartTime = 30;
    
    /// <summary>
    /// 特殊事件触发概率（百分比）
    /// </summary>
    public const int SpecialEventChance = 10;
    
    /// <summary>
    /// 中心争夺区面积计算倍数
    /// </summary>
    public const float CenterZoneAreaMultiplier = 1.5f;
    
    #endregion

    #region 性能和网络
    
    /// <summary>
    /// 状态同步间隔（毫秒）
    /// </summary>
    public const int StateSyncInterval = 50;
    
    /// <summary>
    /// 批量操作最大数量
    /// </summary>
    public const int MaxBatchSize = 10;
    
    /// <summary>
    /// 轨迹点最大缓存数量
    /// </summary>
    public const int MaxTrailPointsCache = 1000;
    
    /// <summary>
    /// 碰撞检测精度（像素）
    /// </summary>
    public const float CollisionDetectionPrecision = 1f;
    
    #endregion

    #region 平衡性调整
    
    /// <summary>
    /// 领先玩家速度减缓比例
    /// </summary>
    public const float LeaderSpeedDebuff = 0.95f;
    
    /// <summary>
    /// 落后玩家道具效果加成比例
    /// </summary>
    public const float CatchupItemBonus = 1.2f;
    
    /// <summary>
    /// 轨迹预警距离（像素）
    /// </summary>
    public const int TrailWarningDistance = 3;
    
    #endregion

    #region 游戏模式配置
    
    /// <summary>
    /// 极速模式速度倍数
    /// </summary>
    public const float SpeedModeMultiplier = 1.5f;
    
    /// <summary>
    /// 道具狂欢模式效果倍数
    /// </summary>
    public const float PowerUpCarnivalEffectMultiplier = 1.5f;
    
    /// <summary>
    /// 生存模式生命数
    /// </summary>
    public const int SurvivalModeLives = 1;
    
    #endregion

    /// <summary>
    /// 根据玩家数量获取推荐地图大小
    /// </summary>
    /// <param name="playerCount">玩家数量</param>
    /// <returns>推荐的地图大小</returns>
    public static int GetRecommendedMapSize(int playerCount)
    {
        return playerCount switch
        {
            <= 4 => SmallMapSize,
            <= 6 => StandardMapSize,
            _ => LargeMapSize
        };
    }

    /// <summary>
    /// 根据游戏模式获取游戏时长
    /// </summary>
    /// <param name="gameMode">游戏模式</param>
    /// <returns>游戏时长（秒）</returns>
    public static int GetGameDuration(string gameMode)
    {
        return gameMode?.ToLower() switch
        {
            "speed" => FastGameDuration,
            "competitive" => CompetitiveGameDuration,
            _ => DefaultGameDuration
        };
    }

    /// <summary>
    /// 根据游戏模式获取移动速度倍数
    /// </summary>
    /// <param name="gameMode">游戏模式</param>
    /// <returns>速度倍数</returns>
    public static float GetSpeedMultiplier(string gameMode)
    {
        return gameMode?.ToLower() switch
        {
            "speed" => SpeedModeMultiplier,
            _ => 1.0f
        };
    }
}
